program fact2
	implicit none
	integer :: n
	print *, "enter  a number"; read *,n
	print *,fact(n)
contains
	recursive function fact(n) result(factorial)
		implicit none
		integer,intent(in) :: n
		integer :: factorial
		if(n==1) then
			factorial=1
			return
		end if
		factorial = fact(n-1)*n
		return
	end function fact
end program